<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="title">
            <h2><a href="#">Usuário</a></h2>
        </ui:define>

        <ui:define name="body">

            <p:panel styleClass="container_24 clearfix">
                <div class="buttonAction" style="float: right">
                    <p:button value="Adicionar" href="criarusuario.xhtml" icon="ui-icon-plusthick"
                              styleClass="ui-priority-primary"/>
                    <p:button value="Pesquisar" href="pesquisarusuario.xhtml" icon="ui-icon-search"/>
                </div>
                <br/>
            </p:panel>

            <h:form id="secretariaForm" enctype="multipart/form-data">            
                <p:messages id="messages" closable="true" showDetail="true" autoUpdate="true"  />
                
                <p:panel id="secretariaPanel" styleClass="container_24 clearfix">

                    <p:dataTable id="tableUsuario" var="item" value="#{managerPesquisarUsuario.usuarios}" 
                                 styleClass="grid_24" rowIndexVar="rowid" 
                                 style="white-space: pre-wrap;"
                                 rowKey="#{item.id}" rows="5" paginator="true"  
                                 paginatorPosition="bottom" emptyMessage="Nenhum registro">  
                        <f:facet name="header">
                            <p:outputLabel value="Campus" />
                        </f:facet>
                        <p:column headerText="Ação" width="10px;" > 
                            <p:button title="Visualizar" 
                                      href="visualizarusuario.xhtml?usuVi=#{item.id}"
                                      icon="ui-icon-zoomin"/> 
                            <p:button title="Alterar" rendered="#{item.id eq managerLayout.usuarioLogado.id}"
                                      href="alterarlogin.xhtml?usuLo=#{item.id}"
                                      icon="ui-icon-unlocked"/> 
                            <p:commandButton title="Excluir" 
                                             rendered="#{managerLayout.admin and (item.id ne managerLayout.usuarioLogado.id)}"
                                             oncomplete="dlg.show();" 
                                             update="@form" 
                                             actionListener="#{managerPesquisarUsuario.setUsuariorr(item)}"
                                             icon="ui-icon-trash"/>
                        </p:column>
                        <p:column sortBy="nome" headerText="Nome" width="300"> 
                            <p:outputLabel value="#{item.nome}"/>
                        </p:column>
                        <p:column sortBy="telefone" headerText="Telefone" width="150"> 
                            <p:outputLabel value="#{item.telefone}"/>
                        </p:column>
                        <p:column sortBy="email" headerText="Email" width="300"> 
                            <p:outputLabel value="#{item.email}"/>
                        </p:column>

                    </p:dataTable>

                </p:panel>

            </h:form>
            <h:form>
                <p:panel id="paneldlg">
                    <p:dialog id="iddlg" header="Exclusão" widgetVar="dlg" modal="false"
                              showEffect="fade" hideEffect="fade" resizable="false" height="20">  
                        <h:outputText value="Deseja Excluir esse Registro ?" /> <br/> 
                        <f:facet name="footer">

                            <center>
                                <p:commandButton value="Sim" id="idb"
                                                 update="@form, :secretariaForm:tableUsuario"
                                                 icon="ui-icon-check"
                                                 actionListener="#{managerPesquisarUsuario.excluir()}"
                                                 />
                                <p:commandButton value="Não" process="@this" onclick="dlg.hide()" icon="ui-icon-close" />
                            </center>

                        </f:facet>
                    </p:dialog>   
                </p:panel>

            </h:form>
        </ui:define>
    </ui:composition>
</html>


